#pragma once

#include<functional>
#include<string>
class task
{
    typedef std::function<int(int,int,char)> func_t;
public:
    //默认构造
    task()
    {}
    //构造函数
    task(int a, int b, char op, func_t func)
        :_a(a)
        ,_b(b)
        ,_op(op)
        ,_func(func)
    {}
 
    //仿函数
std::string operator()()
    {
        int result = _func(_a, _b, _op);
        char buffer[64];
        snprintf(buffer, sizeof(buffer), "%d %c %d = %d\n", _a, _op, _b, result);
        std::string s(buffer);
        return s;
    }
 
    //显示任务
    std::string show_task()
    {
        char buffer[64];
        snprintf(buffer, sizeof(buffer), "%d %c %d = ?\n", _a, _op, _b);
        std::string s(buffer);
        return s;
    }
private:
    func_t _func;
    int _a;
    int _b;
    char _op;
};